home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / misc / dspice0s / magphs.c < prev    next >
C/C++ Source or Header  |  1992-11-21  |  2KB  |  66 lines

  1. /* magphs.f -- translated by f2c (version of 3 February 1990  3:36:42).
  2.    You must link the resulting object file with the libraries:
  3.     -lF77 -lI77 -lm -lc   (in that order)
  4. */
  5.  
  6. #include "f2c.h"
  7.  
  8. /* Common Block Declarations */
  9.  
  10. struct {
  11.     doublereal twopi, xlog2, xlog10, root2, rad, boltz, charge, ctok, gmin, 
  12.         reltol, abstol, vntol, trtol, chgtol, eps0, epssil, epsox, pivtol,
  13.          pivrel;
  14. } knstnt_;
  15.  
  16. #define knstnt_1 knstnt_
  17.  
  18. /*<       subroutine magphs(cvar,xmag,xphs) >*/
  19. /* Subroutine */ int magphs_(cvar, xmag, xphs)
  20. complex *cvar;
  21. doublereal *xmag, *xphs;
  22. {
  23.     /* Builtin functions */
  24.     double r_imag(), sqrt(), atan2();
  25.  
  26.     /* Local variables */
  27.     static doublereal ximag, xreal;
  28.  
  29. /*<       implicit double precision (a-h,o-z) >*/
  30.  
  31. /*     this routine computes the magnitude and phase of its complex arg- 
  32. */
  33. /* ument cvar, storing the results in xmag and xphs. */
  34.  
  35. /* spice version 2g.6  sccsid=knstnt 3/15/83 */
  36. /*<       common /knstnt/ twopi,xlog2,xlog10,root2,rad,boltz,charge,ctok, >*/
  37. /*<      1   gmin,reltol,abstol,vntol,trtol,chgtol,eps0,epssil,epsox, >*/
  38. /*<      2   pivtol,pivrel >*/
  39. /*<       complex cvar >*/
  40.  
  41.  
  42. /*<       xreal=dble(real(cvar)) >*/
  43.     xreal = (doublereal) cvar->r;
  44. /*<       ximag=dble(aimag(cvar)) >*/
  45.     ximag = (doublereal) r_imag(cvar);
  46. /*<       xmag=dsqrt(xreal*xreal+ximag*ximag) >*/
  47.     *xmag = sqrt(xreal * xreal + ximag * ximag);
  48. /*<       if (xmag.ge.1.0d-20) go to 10 >*/
  49.     if (*xmag >= 1e-20) {
  50.     goto L10;
  51.     }
  52. /*<       xmag=1.0d-20 >*/
  53.     *xmag = 1e-20;
  54. /*<       xphs=0.0d0 >*/
  55.     *xphs = 0.;
  56. /*<       return >*/
  57.     return 0;
  58. /*<    10 xphs=rad*datan2(ximag,xreal) >*/
  59. L10:
  60.     *xphs = knstnt_1.rad * atan2(ximag, xreal);
  61. /*<       return >*/
  62.     return 0;
  63. /*<       end >*/
  64. } /* magphs_ */
  65.  
  66.